package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class UserOrder extends BaseDomain{

    public static final Integer STATE_BACK = 0; //待支付
    public static final Integer STATE_SEND = 1; //已支付

    private String orderNumber;//订单号

    private Long userId;//用户Id

    private String userName;//用户名

    private Integer state=STATE_BACK;//状态

    private Long productId;//商品Id

    private String productName;//商品名称

    private String coverUrl;//商品图标

    private Integer integral;//商品积分

    public String getStateName(){
        String msg = "";
        if(state == STATE_BACK){
            msg = "待支付";
        }else if(state == STATE_SEND){
            msg = "已支付";
        }
        return msg;
    }

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("orderNumber",orderNumber);
        map.put("userId",userId);
        map.put("userName",userName);
        map.put("state",state);
        return JSONUtil.toJSONString(map);
    }
}